<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.SmsModule.bean.*,com.SmsModule.dao.*,com.UserModule.dao.*,com.order.bean.*,com.dati.bean.*,com.dati.dao.*,com.dianbo.bean.*,com.dianbo.dao.*"%>  
<%@ page import="util.*" %>
<%
	List<TbOrder> orderDatiList = (ArrayList<TbOrder>) session.getAttribute("orderDatiList");
	List<TbOrder> orderDianboList = (ArrayList<TbOrder>) session.getAttribute("orderDianboList");
	
	  //---------分页
	    int currentPage=1;
	    if(request.getParameter("Page")!=null)
	    {
	    	currentPage=Integer.parseInt(request.getParameter("Page"));
	    }
	//System.out.println("size==" + SmsContentList.size());
%>

<jsp:include page="../head.jsp"></jsp:include>
<body>
<div id="pager">
<jsp:include page="../top.jsp"><jsp:param name="topCurrent" value="2" /></jsp:include>    
<jsp:include page="Left.jsp">
<jsp:param name="um" value="11" /></jsp:include> 
<script type="text/javascript">
var inNum=1;
var tabArray=$('.tabs>.tabs-panel');
var liArray=$('.tabs>.tabs-nav>li');
for(var i=0;i<tabArray.length;i++){
  if(inNum==i){
  	 liArray[i].className='tabs-selected';
  	 tabArray[i].style.display='block';
  }else{
  	liArray[i].className='';
  	tabArray[i].style.display='none';
  }
}
</script>
		<section id="container">
        <div id="crumbs">
        	指令管理 &raquo; 指令设置
        </div>
    <div id="main">
			<div class="tabs">
				<ul class="tabs-nav clearfix">
					<li>
						点播指令设置
					</li>
					<li>
						答题指令设置
					</li>
				</ul>
				<div class="tabs-panel">
				<%
			try{
		 	 String resultSM=session.getAttribute("result").toString();
			 if(!resultSM.equals("")){
				 out.println("<script>alertmess('"+resultSM+"');</script>");
				 session.removeAttribute("result");
			 }
			 }catch(Exception ex){
			 
			 }
		 	%>
				 <form action="" method="post" id="form1" name="form1">
					<table width="100%" class="datalist">
						<thead>
						    <tr><td></td><td><input type="button" name="addOrder" id = "addOrder" value="新建指令" onclick="form1.mb=$.msgbox({
                    	        height:400,
                    	        width:500,
                    	        content:{type:'ajax', content:'TbOrderServlet?method=addOrder&orderType=0&formName=form1'},
                    	        title: '新建指令'
                    	    });"/>
                    	    </td><td colspan="4"></td></tr>
							<tr>
								<td class="tc">
									<input type="checkbox" title="全选" onClick="check_allSM('deleteAll')"/>
								</td>
								<td>
									类型名称
								</td>
								<td>
									指令
								</td>
								<td>
									时间
								</td>
								<td>
									操作
								</td>
							</tr>
						</thead>
						<%
							int i=0; 
							//--------------分页
							//--excel start
							if(orderDianboList!=null)
        					{
					        	//---excel end
								MyPagination mPages=new MyPagination();
								orderDianboList=mPages.getInitPage(orderDianboList,currentPage,10);
								if (orderDianboList != null && orderDianboList.size() > 0){
									for (TbOrder tborder : orderDianboList){
										i++;
										String typeId=tborder.getTypeId();
										String orderName = "";
										DianboType dianboType = new DianboTypeDao().getDianboType(typeId);
										if(dianboType!=null){
											orderName = dianboType.getTypeName();
										}
										
								%>
								<tr>
								<td class="tc">
									<input name="deleteAll" id = "deleteAll" type="checkbox" value="<%=tborder.getOrderId() %>"/>
								</td>
								<td><%=orderName %></td>
								<td><%=tborder.getOrderValue() %></td>
								<td><%=tborder.getCreateTime() %></td>
								<td class="tc"> <a href="javascript:void(0);" class="duanyu_edit" onclick="form1.mb=$.msgbox({
                    	        height:350,
                    	        width:450,
                    	        content:{type:'ajax',content:'TbOrderServlet?method=modifyOrder&id=<%=tborder.getOrderId() %>&formName=form1'},
                    	        title: '修改指令'
                    	    });">修改</a>
                    	    <a title="删除指令" class="duanyu_del" style="cursor:hand" 
								onClick="delOrder('../TbOrderServlet?method=del&id=<%=tborder.getOrderId() %>')" >
								删除</a></td>
								<%
								  }
								 }
								%>
								<%=mPages.printCtrl("hudong/orderList.jsp",currentPage)  %>
								</tr>
								<%
							}
						 %>
						 
					</table>
					 
			 </form>
				</div>
				<div class="tabs-panel">
				<%
			try{
		 	 String resultSM=session.getAttribute("result").toString();
			 if(!resultSM.equals("")){
				 out.println("<script>alertmess('"+resultSM+"');</script>");
				 session.removeAttribute("result");
			 }
			 }catch(Exception ex){
			 
			 }
		 	%>
				 <form action="" method="post" id="form2" name="form2">
					<table width="100%" class="datalist">
						<thead>
						    <tr><td></td><td><input type="button" name="addOrder" id = "addOrder" value="新建指令" onclick="form2.mb=$.msgbox({
                    	        height:400,
                    	        width:500,
                    	        content:{type:'ajax', content:'TbOrderServlet?method=addOrder&orderType=1&formName=form2'},
                    	        title: '新建指令'
                    	    });"/>
                    	    </td><td colspan="4"></td></tr>
							<tr>
								<td class="tc">
									<input type="checkbox" title="全选" onClick="check_allSM('deleteAll')"/>
								</td>
								<td>
									类型名称
								</td>
								<td>
									指令
								</td>
								<td>
									时间
								</td>
								<td>
									操作
								</td>
							</tr>
						</thead>
						<%
							int j=0; 
							//--------------分页
							//--excel start
							if(orderDatiList!=null)
        					{
					        	//---excel end
								MyPagination mPages=new MyPagination();
								orderDatiList=mPages.getInitPage(orderDatiList,currentPage,10);
								if (orderDatiList != null && orderDatiList.size() > 0){
									for (TbOrder tborder : orderDatiList){
										j++;
										String typeId=tborder.getTypeId();
										String orderName = "";
										DatiType datiType = new DatiTypeDao().getDatiType(typeId);
										if(datiType!=null){
											orderName = datiType.getTypeName();
										}
								%>
								<tr>
								<td class="tc">
									<input name="deleteAll" id = "deleteAll" type="checkbox" value="<%=tborder.getOrderId() %>"/>
								</td>
								<td><%=orderName %></td>
								<td><%=tborder.getOrderValue() %></td>
								<td><%=tborder.getCreateTime() %></td>
								<td class="tc"> <a href="javascript:void(0);" class="duanyu_edit" onclick="form2.mb=$.msgbox({
                    	        height:350,
                    	        width:450,
                    	        content:{type:'ajax',content:'TbOrderServlet?method=modifyOrder&id=<%=tborder.getOrderId() %>&formName=form2'},
                    	        title: '修改指令'
                    	    });">修改</a>
                    	    <a title="删除指令" class="duanyu_del" style="cursor:hand" 
								onClick="delOrder('../TbOrderServlet?method=del&id=<%=tborder.getOrderId() %>')" >
								删除</a></td></tr>
								<%
								  }
								 }
								%>
								<%=mPages.printCtrl("hudong/orderList.jsp",currentPage)  %>
								<%
							}
						 %>
					</table>
					 
			 </form>
				</div>
		</div>
		</section>
		  <jsp:include page="../foot.jsp"></jsp:include>
		  </div>
		  </div>
		  
	</body>
</html>
